package com.xiaoxx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoxx.model.dto.sys.SysLogQuery;
import com.xiaoxx.model.entity.sys.SysLog;
import com.xiaoxx.mapper.SysLogMapper;
import com.xiaoxx.model.entity.sys.SysRole;
import com.xiaoxx.model.vo.sys.SysLogVo;
import com.xiaoxx.model.vo.sys.SysRoleVo;
import com.xiaoxx.service.SysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoxx.utils.BeanDtoVoUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * base--sys--操作记录 服务实现类
 * </p>
 *
 * @author HX
 * @since 2023-08-02
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {

    @Override
    public IPage<SysLogVo> listLog(SysLogQuery query) {
        Page<SysLog> sysRolePage = page(new Page<SysLog>(query.getCurrent(), query.getSize()), new LambdaQueryWrapper<SysLog>()
                .like(StringUtils.hasLength(query.getFullName()), SysLog::getFullName, query.getFullName())
                .orderByDesc(SysLog::getCreateTime));
        return BeanDtoVoUtil.pageVo(sysRolePage, SysLogVo.class);
    }
}
